package com.pxxy.springmvc.mapper;

import com.pxxy.springmvc.entity.User;
import org.apache.ibatis.annotations.*;

import java.io.Serializable;
import java.util.List;

/*****
 * 用户数据的持久层
 */
//@Mapper
public interface UserMapper {

    /*@Insert("insert into t_user(id,user_name,password,mobile_phone,real_name,\n" +
            "                           create_date,update_date,last_login_date,status,avatar_url)\n" +
            "        values\n" +
            "        (null,#{userName}, #{password}, #{mobilePhone}, #{realName},\n" +
            "         now(),now(), #{lastLoginDate},\n" +
            "         #{status}, #{avatarUrl})")*/
    int save(User user);

    /*@Update("update t_user set user_name=#{userName} ,password=#{password} ,mobile_phone=#{mobilePhone} ," +
            "real_name=#{realName},update_date=now(),status=#{status} ,avatar_url=#{avatarUrl}")*/
    int update(User user);

    //@Delete("delete from t_user where id = #{value}")
    int delete(Serializable id);

    //@Select("select * from t_user")
    List<User> findAll();

    //@Select("select * from t_user where id = #{value}")
    User findById(Serializable id);

    //@Select("select * from t_user where user_name = #{value}")
    User findByUserName(String userName);
}
